package com.dingreading.cloud.ssxcx.service.impl;

import com.dingreading.cloud.ssxcx.dto.MembersDto;
import com.dingreading.cloud.ssxcx.entity.table.MembersTableDef;
import com.ibm.icu.impl.UResource;
import com.mybatisflex.core.query.QueryCondition;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.dingreading.cloud.ssxcx.entity.Members;
import com.dingreading.cloud.ssxcx.mapper.MembersMapper;
import com.dingreading.cloud.ssxcx.service.MembersService;
import org.springframework.stereotype.Service;

/**
 * 服务层实现。
 *
 * @author EDY
 * @since 2025-10-31
 */
@Service
public class MembersServiceImpl extends BaseServiceImpl<MembersMapper, Members, MembersTableDef> implements MembersService {

    @Override
    protected MembersTableDef getTable() {
        return MembersTableDef.members;
    }

    @Override
    public MembersDto getByUid(String uid) {
        QueryCondition condition = QueryCondition.createEmpty()
                .and(table.uid.eq(uid))
                .and(table.enabled.eq(1));
        QueryWrapper wrapper = QueryWrapper.create()
                .where(condition);
        return getMapper().selectOneByQueryAs(wrapper, MembersDto.class);
    }

    @Override
    public Members getByUids(String uid) {
        return getMapper().selectOneByCondition(table.uid.eq(uid));
    }
}
